/**
 * 
 */
package npap.cater.unr.edu.client.managed.ui.customized;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Inject;
import npap.cater.unr.edu.client.managed.activity.ApplicationDetailsActivities;
import npap.cater.unr.edu.client.managed.activity.ContactActivitiesMapper;
import npap.cater.unr.edu.client.managed.activity.FileActivitiesMapper;
import npap.cater.unr.edu.client.managed.request.ApplicationEntityTypesProcessor;
import npap.cater.unr.edu.client.managed.request.ApplicationRequestFactory;
import npap.cater.unr.edu.client.proxy.ContactProxy;
import npap.cater.unr.edu.client.proxy.FileProxy;
import npap.cater.unr.edu.client.proxy.ProjectProxy;
import npap.cater.unr.edu.client.scaffold.place.ProxyPlace.Operation;
import npap.cater.unr.edu.client.scaffold.place.customized.AppPlace;

/**
 * @author Hao
 *
 */
public class CustomizedApplicationDetailsActivities extends
		ApplicationDetailsActivities {
	@Inject
	public CustomizedApplicationDetailsActivities(
			ApplicationRequestFactory requestFactory,
			PlaceController placeController) {
		super(requestFactory, placeController);
		// TODO Auto-generated constructor stub
	}

	@Override
	public Activity getActivity(Place place) {
		if (place instanceof AppPlace) {
			final AppPlace appPlace = (AppPlace) place;
	        return new ApplicationEntityTypesProcessor<Activity>() {

	            @Override
	            public void handleContact(ContactProxy proxy) {
	            	if(!appPlace.getOperation().equals(Operation.LIST))
	                setResult(new ContactActivitiesMapper(requests, placeController).getActivity(appPlace));
	            }

	            @Override
	            public void handleProject(ProjectProxy proxy) {
//	                setResult(new ProjectActivitiesMapper(requests, placeController).getActivity(proxyPlace));
	            }

				@Override
				public void handleFile(FileProxy proxy) {
					// TODO Auto-generated method stub
					if(!appPlace.getOperation().equals(Operation.LIST))
					setResult(new FileActivitiesMapper(requests, placeController).getActivity(appPlace));
				}
	        }.process(appPlace.getProxyClass());
		} 
        
        return super.getActivity(place);
    }

}
